#include "bottomsidebar.h"
#include "custombutton.h"
#include <QPainter>
#include <QStyleOption>

BottomSidebar::BottomSidebar(QWidget *parent) : QWidget(parent) {

    // 以样式表方式绘制自身
    setAutoFillBackground(true);
    setStyleSheet("background-color: white;"  // 白色填充背景
                  "border: 2px solid rgb(229, 142, 72);"  // 橙色实线描边
                  "border-radius: 40px;");
    setFixedSize(400, 200); // 设置自身固定大小
    move(0, 30);  //设置相对父控件位置

    // 主页按钮
    homeButton = new CustomButton("://res/UI/icon-home.png", 30, 15, this);
    //connect(HomeButton, &CustomButton::clicked, parent, &QWidget::close);

    // 论坛按钮
    forumButton = new CustomButton("://res/UI/icon-forum.png", 100, 15, this);
    //connect(ForumButton, &CustomButton::clicked, parent, &QWidget::close);

    // 消息按钮
    messageButton = new CustomButton(":/res/UI/icon-message.png", 245, 15, this);
    //connect(MessageButton, &CustomButton::clicked, parent, &QWidget::close);

    // 个人按钮
    userButton = new CustomButton(":/res/UI/icon-user.png", 315, 15, this);
    //connect(UserButton, &CustomButton::clicked, parent, &QWidget::close);
}


// 重写paintEvent成员函数
void BottomSidebar::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event);

    // 样式表绘制启用
    QPainter p(this);
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

